/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			ETVpCmd_NewTopElem.h
  \date			Sep 2011
  \author		TNick

  \brief		Contains the definition for ETVpCmd_NewTopElem class


  Copyright (c) 2011, Nicu Tofan
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
 * Neither the name of the copyright holder nor the
   names of its contributors may be used to endorse or promote products
   derived from this software without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL NICU TOFAN BE LIABLE FOR ANY
 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __ETVPCMD_NEWTOPELEM_INC__
#define __ETVPCMD_NEWTOPELEM_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<sheet/ETVpCommand.h>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

/// command that creates a new item in a sheet
/**
*	The user of this class calls one of the createEquation(), createFunction()
*	or createTextBox() static functions to start a new command. The start()
*	function simply changes the mouse pointer and waits for the user to pick
*	a point. It then inserts th newly created object at that position,
*	makes it curret and deletes itself.
*/
class ETVpCmd_NewTopElem : public ETVpCommand 		{

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	/// the type of object that is created with active command
	enum		CmdType		{
		CREATE_FUNCTION,
		CREATE_EQUATION,
		CREATE_MTEXT,

		MAX_TY
	};

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

private:

	/// the type of object to create when the user chooses a point
	CmdType			ty;

	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

private:

	/// constructor;
	ETVpCmd_NewTopElem		( void );

public:

	/// destructor;
	virtual				~ETVpCmd_NewTopElem		( void );


	/// the class is informed that the command is starting
	/**
	  *	Commands are started by creating an instance of a class inherited from
	  *	ETVpCommand and passing it to startCommand(). While current implementation
	  *	will always call ETVpCommand::start(), this may change in the future. As a
	  *	result the command (class) shall only initialise itself when it recieves
	  *	the ETVpCommand::start(), not in constructor.
	  *
	  *	@return		true to continue loading or false to cancel
	  */
	bool				start		(
			ETSheetView *		trg_vp		/**< target viewport */
			);


	/// the class is informed that the command is being canceled
	/**
	  *	The call to this function may or may not be preceded by a call to
	  *	accepted(), depending on the user actions. It is usually called
	  *	just before destroying the instance. However, the implementations
	  *	shall free allocated resources here and not in destructor.
	  */
	void				cancel		(
			ETSheetView *		trg_vp		/**< target viewport */
			);

protected:

	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
	/** @name Events forwarded by the viewport    */
	//@{
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */

	bool		mousePress	(
			ETSheetView *	vp,
			QMouseEvent * event);


	//@}
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */



public:

	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
	/** @name Exported commands    */
	//@{
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */

	/// places the viewport in command mode; an equation is created
	static void	createEquation		(ETSheetView * trg_vp);

	/// places the viewport in command mode; a function is created
	static void	createFunction		(ETSheetView * trg_vp);

	/// places the viewport in command mode; a text box is created
	static void	createTextBox		(ETSheetView * trg_vp);


	//@}
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */



	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class ETVpCmd_NewTopElem	*/

/*  CLASS    =============================================================== */
//
//
//
//
#endif // __ETVPCMD_NEWTOPELEM_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
